﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using Provider;
using System.Data;

namespace AccessToDataEnergyLibrury
{
   public partial class AccessDataEnergyLibrury
    {
       /// <summary>
        /// Метод возвращает все документы из таблицы Documentation и связаных таблиц
        /// </summary>
        /// <returns></returns>
        public List<Address> GetAllAddress()
        {
            DataRowCollection searchedRow = this.energyDataSet.address.Rows;

            return this.GetRestPartsOfAddress(searchedRow);
        }

        List<Address> GetRestPartsOfAddress(DataRowCollection searchedRows)
        {
            if (searchedRows == null || searchedRows.Count == 0)
            {
                return null;
            }
            else
            {
                List<Address> addressa = new List<Address>();

                foreach (energyzmemDataSet.addressRow addressaRow in searchedRows)
                {
                    Address address = new Address();
                    address.ID = addressaRow.id_Adress;
                    address.Country = addressaRow.country;
                    address.Republic = addressaRow.republic;
                    address.Region = addressaRow.region;
                    address.Area = addressaRow.area;
                    address.Locality = addressaRow.locality;
                    address.Street = addressaRow.street;
                    address.HourseNumber = addressaRow.house_number;
                    address.ApartmentsNumber = addressaRow.apartment_number;
                    address.Phone = addressaRow.phone;
                    address.Fax = addressaRow.fax;
                    address.Email = addressaRow.email;

                   addressa.Add(address);
                }
                return addressa;
            }
        }
    }
}
